#include <Qt/qcoreapplication.h>
#include <qsettings.h>
#include "mdxserver.h"
#include "mlog.h"

#include <qdebug.h>


#define CFGNAME "rzld.cfg"
#define MODNAME "Main"


int main(int argc, char ** argv){
    QCoreApplication app(argc,argv);
    //fixit конфиг прописан пока внаглую, переделать.
    QSettings cfg(QCoreApplication::applicationDirPath()+"/"+CFGNAME,QSettings::IniFormat);

    MLog logger;
    logger.setLevel(cfg.value("loglevel",3).toInt());
    logger.slotPut(MODNAME,3,"start");

    MDxserver server;
    server.connect(&server,SIGNAL(sigLog(QString,int,QString)),&logger,SLOT(slotPut(QString,int,QString)));
    server.setPort(cfg.value("port",7777).toInt());
    server.setBase(cfg.value("dbaddr","").toString(),cfg.value("dbuser","").toString(),
                   cfg.value("dbpass","").toString(),cfg.value("dbname","").toString(),
                   cfg.value("dbport",3306).toInt());
    server.setSessionTtl(cfg.value("session_ttl",600).toInt());
    server.start();

    return app.exec();
}
